//
//  Type_1CViewCell.m
//  Travel_M_Travel
//
//  Created by Sun on 15/3/26.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "Type_1CViewCell.h"

@implementation Type_1CViewCell

- (void)dealloc
{
    [_imageFirView release];
    [_title release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 定义cell单元格内容
        _imageFirView = [[UIImageView alloc] init];
        _imageFirView.clipsToBounds = YES;
        _imageFirView.layer.cornerRadius = 5;
        [self addSubview:_imageFirView];
        [_imageFirView release];
        
        self.title = [[UILabel alloc] init];
        self.title.textColor = [UIColor whiteColor];
        //        self.title.backgroundColor = [UIColor blueColor];
        self.title.textAlignment = NSTextAlignmentCenter;
        self.title.font = [UIFont systemFontOfSize:30];
        [self addSubview:self.title];
        [_title release];
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _imageFirView.frame = CGRectMake(0, 0, 320, 150);
    [self.title setFrame:CGRectMake(0, 0, 320, 70)];
    self.title.center = CGPointMake(self.imageFirView.frame.size.width / 2, self.imageFirView.frame.size.height /  2);
}

- (void)setAboutData1:(AboutDataData *)aboutData1
{
    if (_aboutData1 != aboutData1) {
        [_aboutData1 release];
        _aboutData1= [aboutData1 retain];
    }
    
    for (NSInteger i = 0; i < 4; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i, 0, self.frame.size.width, 150)];
        NSString *str = self.aboutData1.image_url;
        //        NSLog(@"~~~~~~~~~~~~~%@",str);
        str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        
        NSURL *url = [NSURL URLWithString:str];
        [imageView setImageWithURL:url];
        // 循环动画
        imageView.clipsToBounds = YES;
        imageView.layer.cornerRadius = 8;
        [_imageFirView addSubview:imageView];
        [imageView release];
    }
}

- (void)setMusicData:(MusicDataSource *)musicData
{
    if (_musicData != musicData) {
        [_musicData release];
        _musicData = [musicData retain];
    }
    for (NSInteger i = 0; i < 4; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width * i, 0, self.frame.size.width, 150)];
        NSString *str = musicData.cover_path;
        //        NSLog(@"~~~~~~~~~~~~~%@",str);
        str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        
        NSURL *url = [NSURL URLWithString:str];
        [imageView setImageWithURL:url];
        // 循环动画
        imageView.clipsToBounds = YES;
        imageView.layer.cornerRadius = 8;
        [_imageFirView addSubview:imageView];
        [imageView release];
        
        self.title.text = musicData.tname;
    }
    
}


//- (void)setType:(CellType)type
//{
//    _type = type;
//
//
//    if (_type == CellTypeFirst) {
//
//    } else if (_type == CellTypeSecond) {
//
//    }
//
//
//}



@end
